package com.gepengjun.springboot.jwt.advice;

import com.gepengjun.springboot.base.JsonResult.Result;
import com.gepengjun.springboot.base.JsonResult.ResultUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public Result runtimeException(Exception exception){
        String msg = exception.getMessage();
        return ResultUtil.error(500,msg);
    }

    @ExceptionHandler()
    public Result jwtException(Exception exception){
        String msg = exception.getMessage();
        return ResultUtil.error(403,msg);
    }
}
